<?php
declare(strict_types=1);

namespace app\validate;

use think\Validate;

class MessageConfigValidate extends Validate
{
    protected $rule = [
        'id' => 'number',
        'type' => 'require|number|between:1,6',
        'scene' => 'require|number|between:1,6'
    ];

    protected $message = [
        'id.require' => 'ID不能为空',
        'id.number' => 'ID必须为数字',
        'type.require' => '消息类型不能为空',
        'type.number' => '消息类型必须为数字',
        'type.between' => '消息类型值范围不正确',
        'scene.require' => '场景类型不能为空',
        'scene.number' => '场景类型必须为数字',
        'scene.between' => '场景类型值范围不正确'
    ];


    public function scene($scene)
    {
        $this->scene = $scene;
        return $this;
    }

    public function checkScene($scene)
    {
        if($scene == 'update'){
            return $this->only(['type','scene']);
        }
        return $this->only(['type','scene']);
    }
} 